<?php
namespace app\api\model\v1;

/*
 * content : 访问权限管理类
 * Author  : Songyicong
 * time    : 2018-04-19 10:41:29
 * email   : m13726262373@163.com
 */

use app\api\model\BaseModel;
use think\Cache;

class Admin extends BaseModel{

    protected $table = "km_admin";

    /** 判断ip是否正确 */
    public function getIpAuth($ip = "",$admin_id = ""){
        if(empty($ip)||empty($admin_id)){
            return false;
        }
        $admin = self::where('id',$admin_id)->find();
        if(!empty($admin)){
            return $admin;
        }
        return false;
    }

    /** 判断appid 和 app_secret是否正确 */
    public static function getSecret($client_id="",$app_secret=""){
        if(empty($client_id)||empty($app_secret)){
            return false;
        }
        $where['client_id'] = $client_id;
        $where['secret'] = $app_secret;
        $results = self::where($where)->find();
        return empty($results)?false:$results->toArray();
    }

    public static function isLogin($login=""){
        if(empty($login)){
            return false;
        }
        $where['login_name'] = $login;
        $results = self::where($where)->find();
        return empty($results)?false:$results->toArray();
    }
    
}
